<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@ include file="/common/meta.jsp"%>
<script type="text/javascript">
var win,alertinfo,grid,form;
$(function() {
	form = $("form[name=listForm]");
	win = $("#win").window({
		title : "添加",
		modal : true
	});
	var columns = [{field:"moduleid", checkbox : true}];
	columns.push({field:'moduleName',title:'模块名称',width:100,sortable:true},
			{field:'moduleCode',title:'模块号',width:120,sortable:true},
			{field:'moduleIcon',title:'模块图标',width:80,sortable:true});
	var config = {
			fit : true,
			striped: true,  
			url : "${ctx}/moduleInfoController.do?method=ajaxlist",
			loadMsg : "数据加载中。。。",
			pagination: true,
			rownumbers : false,
			pageList : [15,20,30,40,50],
			columns:[columns],
			onBeforeLoad : function(params) {
				var p = $("form[name=listForm]").getFormParams();
				$.extend(params, p);
			}
		};
	grid = $("#dataGrid").datagrid(config);
	$("#btn_add").click(function() {
		win.window('open');
		win.window("setTitle","新增");
		alertinfo="添加";
		$("#msg").load("${ctx}/moduleInfoController.do?method=add");
	});
	$("#btn_modify").click(function() {
		var rows = grid.datagrid("getSelections");
		if (rows.length > 1) {
			alert("只能选择一条记录");
			return;
		}
		if (rows.length==0){
			alert("请选择记录！");
			return;
		}
		var ids = getSelectedBy(rows, "moduleid");
		if (ids) {
			win.window('open');
			win.window("setTitle","修改");
			alertinfo="修改";
			$("#msg").load("${ctx}/moduleInfoController.do?method=modify",{id : ids});
		}
	});
	$("#btn_delete").click(function() {
		var rows = grid.datagrid("getSelections");
		var ids = getSelectedBy(rows, "moduleid");
		if (!ids) {
			alert("请选择记录！");
			return;
		}
		if (!confirm("确定删除选中的记录吗？"))
			return;
		form.attr("action", "${ctx}/moduleInfoController.do?method=delete&ids=" + ids);
		submit(form,function(res,status){
			if(isSuccess(res,status)){
				grid.datagrid("reload");
				showTip("删除成功");
			}else showTip("删除失败");
		});
	});
	$("#btn_query").click(function() {
		grid.datagrid("reload");
	});
	fit("#container");
});
</script>
</head>
<body>
	<form method="post" action="
		${ctx}/moduleInfoController.do?method=list " name="listForm">
		<div
			style="width: 100%; height: 500px; margin: auto; position: relative;"
			id="container">
			<div class="datagrid-toolbar" region="north" style="height: 40px;background-color: white;" border="false">
				<lbm:auth operate="ADD" module="MODULEDFI" iconCls="icon-add" id="btn_add" value="添加"></lbm:auth>
				<lbm:auth operate="EDIT" module="MODULEDFI" iconCls="icon-edit" id="btn_modify" value="修改"></lbm:auth>
				<lbm:auth operate="DELETE" module="MODULEDFI" iconCls="icon-remove" id="btn_delete" value="删除"></lbm:auth>
			</div>
			<div region="center" border="false">
				<table id="dataGrid"></table>
			</div>
		</div>
	</form>
	<div id="win" closed="true" style="width: 400px; height: 300px;">
		<div id="msg"></div>
	</div>
</body>
</html>